package com.jinyi.wwdeng.ui.config.adapter

import androidx.recyclerview.widget.RecyclerView
import cn.bingoogolapple.baseadapter.BGARecyclerViewAdapter
import cn.bingoogolapple.baseadapter.BGAViewHolderHelper
import com.jinyi.wwdeng.R
import org.json.JSONObject

/**
 * JinYiTest
 * @Author wwdeng
 * @CreateTime: 2024/4/19 12:02
 * @Annotation：确认绑卡适配器
 */
class ConfirmBindCardAdapter(recyclerView: RecyclerView?): BGARecyclerViewAdapter<JSONObject>(recyclerView) {

    override fun getItemViewType(position: Int): Int {
        val model = getItem(position)
        if (model.optBoolean("isEdit",false)){
            return R.layout.item_bind_card_edit
        }
        return R.layout.item_bind_card
    }

    override fun setItemChildListener(helper: BGAViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.editLayout) //点击编辑
        helper.setItemChildClickListener(R.id.cardLayout) //点击查看
        helper.setItemChildClickListener(R.id.btnDelete)//删除
    }

    override fun fillData(helper: BGAViewHolderHelper, position: Int, model: JSONObject) {
        helper.setText(R.id.tvIndex,String.format(mContext.getString(R.string.portefeuille_mobile),position+1))

        //是否是编辑
        val isEdit = model.optBoolean("isEdit",false)
        if (isEdit){

        } else {

        }
    }
}